﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>ZRender</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="ZRender">
    <meta name="author" content="kener.linfeng@gmail.com">

    <script src="../asset/js/esl/esl.js"></script>
    <script src="../asset/js/codemirror.js"></script>
    <script src="../asset/js/javascript.js"></script>

    <link href="../asset/css/bootstrap.css" rel="stylesheet">
    <link href="../asset/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="../asset/css/codemirror.css" rel="stylesheet">
    <link href="../asset/css/monokai.css" rel="stylesheet">
    <link href="../asset/css/zrenderHome.css" rel="stylesheet">
    <link rel="shortcut icon" href="../asset/ico/favicon.png">
</head>

<body>
    <!-- NAVBAR
    ================================================== -->
    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="brand" href="../../index.html">ZRender</a>
          <div class="nav-collapse collapse">
              <a id="forkme_banner" href="https://github.com/ecomfe/zrender">View on GitHub</a>
              <ul class="nav">
                <li><a href="../../index.html"><i class="icon-home icon-white"></i> Home</a></li>
                <li class="active dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Example <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <li><a href="demo.html">Demo</a></li>
                    <li><a href="animation.html">Animation</a></li>
                    <li class="active"><a href="chart.html">Chart</a></li>
                    <li><a href="colorSeries.html">Color Series</a></li>
                    <li class="divider"></li>
                    <!--li class="nav-header">Library</li-->
                    <li><a href="artist.html">Artist</a></li>
                    <li><a href="slice.html">slice</a></li>
                  </ul>
                </li>
                <li><a href="../api/index.html" target="_blank">API &amp; Doc</a></li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-download-alt icon-white"></i>Download <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <li><a href="https://github.com/ecomfe/zrender/archive/2.1.0.zip">ZIP (2.1.0)</a></li>
                    <li><a href="https://github.com/ecomfe/zrender/archive/master.zip">ZIP (Latest)</a></li>
                  </ul>
                </li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Link <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <li><a href="https://github.com/ecomfe" target="_blank">Ecom-FE</a></li>
                    <li><a href="http://fe.baidu.com/doc/ecom/tech/topic/dv/index.html" target="_blank">Data Visualization</a></li>
                    <li class="divider"></li>
                    <!--li class="nav-header">Library</li-->
                    <li><a href="http://echarts.baidu.com" target="_blank">ECharts</a></li>
                  </ul>
                </li>
              </ul>
           </div><!--/.nav-collapse -->
        </div><!-- /.container -->
      </div><!-- /.navbar-inner -->
    </div><!-- /.navbar-wrapper -->

    <div class="container-fluid">
        <div class="row-fluid">
            <div id="sidebar-code" class="span4">
                <div class="well sidebar-nav">
                    <div class="nav-header">code
                    <a href="#" onclick="autoResize()" class="icon-resize-full" id ="icon-resize" ></a>
                    </div>
                    <textarea id="code" name="code">
/*
 *  zr has been init like this, just use it!
 *
 *  var zrender = require('zrender');
 *  var zr = zrender.init(document.getElementById('main'));
 */
zr.clear();
var Base = require('zrender/shape/Base');
function Cross(options) {
    Base.call(this, options);
}
Cross.prototype = {
    type : 'cross',
    brush : function(ctx, isHighlight) {
        var style = this.style || {};
        if (isHighlight) {
            // 根据style扩展默认高亮样式
            style = this.highlightStyle || {};
            for (var k in this.style) {
                style[k] = this.style[k];
            }
        }
        ctx.save();
        ctx.beginPath();
        ctx.strokeStyle = style.strokeColor || style.color;
        ctx.moveTo(style.x - style.width / 2, style.y);
        ctx.lineTo(style.x + style.width / 2, style.y);
        ctx.moveTo(style.x, style.y - style.height / 2);
        ctx.lineTo(style.x, style.y + style.height / 2);
        ctx.closePath();
        ctx.stroke();
        ctx.restore();
        return;
    },

    drift : function(dx, dy) {
        this.style.x += dx;
        this.style.y += dy;
    },

    isCover : function(x, y) {
        var originPos = this.getTansform(x, y);
        x = originPos[0];
        y = originPos[1];

        if (x >= (this.style.x - this.style.width / 2)
            && x <= (this.style.x + this.style.width / 2)
            && y >= this.style.y - this.style.height / 2
            && y <= (this.style.y + this.style.height / 2)
        ) {
            return true;
        }
        return false;
    }
}
require('zrender/tool/util').inherits(Cross, Base);

zr.addShape(new Cross({
    style : {
         x : 100,
         y : 100,
         width : 50,
         height : 50,
         color : 'red'
    },
    draggable : true
}));

function Audi(options) {
    this.brushTypeOnly = 'stroke';
    Base.call(this, options);
}
Audi.prototype = {
    type : 'auid',
    buildPath : function(ctx, style) {
        var x = style.x;
        var y = style.y;
        var r = style.r;
        for (var i = 0; i < 4; i++) {
            ctx.arc(x, y, r, 0, Math.PI * 2, true);
            ctx.moveTo(x + 5 * r / 2, y);
            x += r * 3 / 2;
        }
        return;
    },

    /**
     * 返回矩形区域，用于局部刷新和文字定位
     * @param {Object} style
     */
    getRect : function(style) {
        return {
            x : Math.round(style.x - style.r),
            y : Math.round(style.y - style.r),
            width : style.r * 6.5,
            height : style.r * 2
        };
    }
}

require('zrender/tool/util').inherits(Audi, Base);
zr.addShape(new Audi({
    style : {
         x : 200,
         y : 100,
         r : 50,
         color : '#1e90ff',
         lineWidth : 1,
         text : 'Audi'
    },
    draggable : true
}));
zr.render();
                    </textarea>
              </div><!--/.well -->
            </div><!--/span-->
            <div id="graphic" class="span8">
                <div id="main" class="main"></div>
                <div>
                    <button onclick="refresh(true)">Refresh ~</button>
                    <span id='wrong-message' style="color:red"></span>
                </div>
            </div><!--/span-->
        </div><!--/row-->
        <hr>
        <!-- FOOTER -->
        <footer>
          <p class="pull-right"><a href="#">Back to top</a></p>
          <p>&copy; 2013 ECOM-FE &middot; <a href="https://github.com/ecomfe/zrender/blob/master/LICENSE.txt" target="_blank">Terms</a> &middot; <a href="../changelog.html" target="_blank">Changelog</a></p>
        </footer>
    </div><!--/.fluid-container-->

    <script src="../asset/js/jquery.js"></script>
    <script src="../asset/js/bootstrap-transition.js"></script>
    <script src="../asset/js/bootstrap-alert.js"></script>
    <script src="../asset/js/bootstrap-modal.js"></script>
    <script src="../asset/js/bootstrap-dropdown.js"></script>
    <script src="../asset/js/bootstrap-scrollspy.js"></script>
    <script src="../asset/js/bootstrap-tab.js"></script>
    <script src="../asset/js/bootstrap-tooltip.js"></script>
    <script src="../asset/js/bootstrap-popover.js"></script>
    <script src="../asset/js/bootstrap-button.js"></script>
    <script src="../asset/js/bootstrap-collapse.js"></script>
    <script src="../asset/js/bootstrap-carousel.js"></script>
    <script src="../asset/js/bootstrap-typeahead.js"></script>
    <script src="../asset/js/zrenderDemo.js"></script>
</body>
</html>